﻿using System.Collections.Generic;

namespace com.binance.client.model.enums
{
	/// <summary>
	/// @author : wangwanlu
	/// @since : 2020/3/25, Wed
	/// 
	/// </summary>
	public sealed class PositionSide
	{

		public static readonly PositionSide BOTH = new PositionSide("BOTH", InnerEnum.BOTH, "BOTH");

		public static readonly PositionSide SHORT = new PositionSide("SHORT", InnerEnum.SHORT, "SHORT");

		public static readonly PositionSide LONG = new PositionSide("LONG", InnerEnum.LONG, "LONG");

		private static readonly IList<PositionSide> valueList = new List<PositionSide>();

		static PositionSide()
		{
			valueList.Add(BOTH);
			valueList.Add(SHORT);
			valueList.Add(LONG);
		}

		public enum InnerEnum
		{
			BOTH,
			SHORT,
			LONG
		}

		public readonly InnerEnum innerEnumValue;
		private readonly string nameValue;
		private readonly int ordinalValue;
		private static int nextOrdinal = 0;

		private readonly string code;

		internal PositionSide(string name, InnerEnum innerEnum, string side)
		{
			this.code = side;

			nameValue = name;
			ordinalValue = nextOrdinal++;
			innerEnumValue = innerEnum;
		}

		public override string ToString()
		{
			return code;
		}

		public static IList<PositionSide> values()
		{
			return valueList;
		}

		public int ordinal()
		{
			return ordinalValue;
		}

		public static PositionSide valueOf(string name)
		{
			foreach (PositionSide enumInstance in PositionSide.valueList)
			{
				if (enumInstance.nameValue == name)
				{
					return enumInstance;
				}
			}
			throw new System.ArgumentException(name);
		}
	}

}